<template>
  <div class="screen-container">
    <div class="screen-header">
      <PipeLinePickCom></PipeLinePickCom>
    </div>
    <div class="screen-body">
      <div class="screen-body-top">
        <div id="top-left">
          <TemperatureCom></TemperatureCom>
        </div>
        <div id="top-right">
          <FlowCom></FlowCom>
        </div>
      </div>
      <div class="screen-body-bottom">
        <div id="bottom-left">
          <TotalFlowCom></TotalFlowCom>
        </div>
        <div id="bottom-right">
          <PressureCom></PressureCom>
          <OilPressureCom></OilPressureCom>
          <CasingPressureCom></CasingPressureCom>
          <DiffPressureCom></DiffPressureCom>
        </div>
      </div>
    </div>
  </div>

  <audio ref="alarmAudio" hidden>
    <source src="../assets/audio/alarm1.wav" type="audio/wav" />
  </audio>
</template>

<script setup name="ScreenPage">
import { shallowRef, onMounted } from 'vue'
import CasingPressureCom from '../components/CasingPressureCom.vue'
import FlowCom from '../components/FlowCom.vue'
import DiffPressureCom from '../components/DiffPressureCom.vue'
import OilPressureCom from '../components/OilPressureCom.vue'
import PressureCom from '../components/PressureCom.vue'
import TemperatureCom from '../components/TemperatureCom.vue'
import PipeLinePickCom from '../components/PipeLinePickCom.vue'
import TotalFlowCom from '../components/TotalFlowCom.vue'
import { useChart } from '../hooks/useChart'
const { openSocket, registerAlarmAudio } = useChart()
const alarmAudio = shallowRef()
onMounted(() => {
  registerAlarmAudio(alarmAudio.value)
  openSocket()
})
</script>

<style lang="less" scoped>
.screen-container {
  width: 100%;
  height: 100%;
  background-color: #161522;
  color: #fff;
}
.screen-header {
  width: 100%;
  height: 12%;
  font-size: 20px;
}
.screen-body {
  width: 100%;
  height: 88%;
  .screen-body-top {
    width: 100%;
    height: 52%;
    display: flex;
    #top-left {
      width: 50%;
      height: 100%;
    }
    #top-right {
      width: 50%;
      height: 100%;
    }
  }
  .screen-body-bottom {
    width: 100%;
    height: 48%;
    display: flex;
    #bottom-left {
      width: 40%;
      height: 100%;
      display: flex;
    }
    #bottom-right {
      width: 60%;
      height: 100%;
      display: flex;
    }
  }
}
</style>
